// OUTDOOR SECTION SCRIPT
//    Section: X = 2, Y = 0

// This is the special encounter script for this town.
// The states INIT_STATE and START_STATE have
// meanings that are described in the documenation. States you write
// yourself should be numbered from 10-100.
//Why is this suddenly playing up now?
beginoutdoorscript;

variables;

short i,j,k,r1,choice;

body;

beginstate INIT_STATE;
// This state called whenever this section is loaded into memory.
break;

beginstate START_STATE;
set_state_continue(28);
break;

beginstate 10;
	reset_dialog();
	add_dialog_str(0,"A small village is perched beneath the Northrange next to a wide river. Life in quiet here, with small fishing and farming the only daily activities.You remark that there are surprisingly few young men, perhaps due to conscription.",0);
	add_dialog_str(1,"For the most part, you travel through unnoticed. As you approach the river, however, some villagers come up to you and look you over.",0);
	add_dialog_str(2,"_We fish along the Eden River,_ one of them says. _You look like folk who'd like a ride across. We'll be full willing._ He nods, motioning to some boats tied to the docks. _What do you say?_",0);
	add_dialog_choice(0,"No.");
	add_dialog_choice(1,"Yes.");
	choice = run_dialog(1);
	if (choice == 1)
		set_state_continue(11);
	if (choice == 2)
		set_state_continue(12);
break;

beginstate 11;
	message_dialog("Seeing your antipathy, the fishermen shrug and wander off.","");
	block_entry(1);
break;

beginstate 12;
	block_entry(1);
	out_move_party(15,36);
break;

beginstate 13;
	message_dialog("You find here the ruins of a tower. Very little of it is recognizable. Perhaps it had once been the dwelling of someone of prominence.",
	  "Whatever it was, it has diminished now into piles of fallen stone.");
break;

beginstate 14;
	if (get_flag(202,0) == 250)
		end();
	reset_dialog();
	add_dialog_str(0,"You meet up with a hunting party of misshapen, monstrous Grendlings. They don't seem at all inclined to talk. Your feeble efforts to make pleasant conversation are met with bared fangs and closed fists.",0);
	add_dialog_choice(0,"OK.");
	choice = run_dialog(1);
	set_flag(202,0,250);
	create_out_spec_enc(0);
break;

beginstate 16;
	if (get_flag(202,1) == 250)
		end();
	reset_dialog();
	add_dialog_str(0,"At the farthest part of the eastern swamps, you find a graveyard. No ordinary burial ground is this.",0);
	add_dialog_str(1,"All along the shore are laid the bones of both humanoids and beasts. It is as though each thing that dies here is called towards the sea. A fog lies over it all, creating a strange ethereal feeling.",0);
	add_dialog_str(2,"In the distance, you see a white gull. Hovering portentiously over the thin edge that separates the life of the sea and the death of the land, it cries out three times, drops, and falls within the reeds.",0);
	add_dialog_str(3,"You stay for a while, but there is nothing else here for you to see.",0);
	add_dialog_choice(0,"OK.");
	choice = run_dialog(1);
	set_flag(202,1,250);
break;

beginstate 17;
	if (get_flag(202,2) == 250)
		end();
	reset_dialog_preset_options(1);
	add_dialog_str(0,"You spot some Spiritual Herbs growing here.",0);
	choice = run_dialog(1);
	if (choice == 2) {
		set_flag(202,2,250);
		reward_give(215);
		}
break;

beginstate 18;
	reset_dialog();
	add_dialog_str(0,"The fishermen are still here.",0);
	add_dialog_str(1,"_Ah, back so soon? 50 gold for the trip over. Pay it or leave it._",0);
	add_dialog_choice(0,"OK.");
	add_dialog_choice(1,"Pay.");
	choice = run_dialog(1);
	if (choice == 2)
		set_state_continue(20);
	set_state_continue(19);
break;

beginstate 19;
	message_dialog("The fisherman shakes his head and smirks. _We'll be waiting._","");
	block_entry(1);
break;

beginstate 20;
	if (coins_amount() >= 50) {
		change_coins(-1 * 50);
		set_state_continue(21);
		}
	set_state_continue(19);
break;

beginstate 21;
	block_entry(1);
	out_move_party(10,36);
break;

beginstate 22;
	message_dialog("Some hunters have taken residence on the far side of the Eden river. Surprised to see outlanders here, they nevertheless invite you in for liquor and conversation.",
	  "As you depart, they tell you to be careful around the area to the southeast, being inhabited by a den of Grendlings, savage swamp monsters.");
break;

beginstate 23;
	if (get_flag(240,8) == 250)
		end();
	reset_dialog();
	add_dialog_str(0,"In the middle of the swamp, you can see a large group of misshapen humanoids. They don't see you yet.",0);
	add_dialog_choice(0,"OK.");
	add_dialog_choice(1,"Attack.");
	choice = run_dialog(1);
	if (choice == 1)
		block_entry(1);
	if (choice == 2){
		create_out_spec_enc(1);	
		set_flag(240,8,250);
		}
break;

beginstate 26;
	if (reward_give(456) > 0) {
	message_dialog("You defeat the Grendling horde. Searching around in their den, you find very little in the way of valuable items or appealing food. That is to say, none at all.",
	  "There is, though, an odd-looking skull. It doesn't seem to be natural. On a whim, you take it.");
	  set_state_continue(28);
		}
break;

beginstate 27;
	message_dialog("The skull disappears as soon as you touch it. Must be some weird trick.","");
break;

beginstate 28;
	if (get_flag(202,0) == 250)
	set_terrain(22,32,0);
	if (get_flag(202,1) == 250)
	set_terrain(33,39,0);
	if (get_flag(240,8) == 250)
	set_terrain(29,35,0);
break;